import msg from "../../../utils/msg";
import { activity_list, getGameList } from "../../../utils/request/api";
import { filePath1 } from "../../../utils/request/route";

// pages/mer/merDetail/merDetail.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {
    showList: [],
    list:[],
    filePath1: filePath1,
  },
  goToDetail(e:any){
    let index = e.currentTarget.dataset.index;
    let data:any = this.data.showList[index];
    wx.navigateTo({
      url:"/pages/compete/comDetail/comDetail"+'?id='+data.id,
    })
  },
  goToDetail2(e:any){
    let index = e.currentTarget.dataset.index;
    let data:any = this.data.list[index];
    wx.navigateTo({
      url:"/pages/act/actDetail/actDetail"+'?id='+data.id,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: async function (option) {
    let club_id = option.id;
    if (!club_id) wx.navigateBack();
    wx.setNavigationBarTitle({
      title: '单位主页',
    });
    msg.Loading();
    let res_act: any = await activity_list({ club_id: club_id });
    msg.hideLoading();
    this.setData({
      list: res_act.data.datas,
    });
    let res_com: any =await getGameList({ club_id: club_id }).then((res: any) => {
      msg.hideLoading();
      if (res.data.error == 0) {
        this.setData({
          showList: res.data.datas,
        });
      }
      else msg.show(res.data.msg);
    });
    msg.hideLoading();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})